<?php

/**
 * News Controller
 * @author PhuND
 */
class News extends CI_Controller {

    public function __construct() {
        parent::__construct();
    }

    /**
     * @todo News Index Page
     * @author PhuND
     */
    public function index() {
        $this->load->helper('html');
        $this->load->model('Mnews_category');
        $this->load->model('Mnews_content');
        $news_categories = $this->Mnews_category->listParent();
        $news_contents = $this->Mnews_content->getTopNew(14);
        
        $temp['title'] = 'Tin tức | Tuyển Dụng 24H';
        $temp['meta'] = array(
            array('name' => 'description', 'content' => ''),
            array('name' => 'keywords', 'content' => '')
        );
        $temp['data']['categories'] = $news_categories;
        $temp['data']['news'] = $news_contents;
        $temp['template'] = 'frontend/news/index';
        $this->load->view("frontend/_layout/default", $temp);
    }

    /**
     * @todo Detail News Category
     * @author PhuND
     */
    public function category($slug) {
        $this->load->helper('html');
        $this->load->model('Mnews_category');
        $news_categories = $this->Mnews_category->listParent();
        $news_category = $this->Mnews_category->getBySlug($slug);

        $temp['title'] = 'Tin tức | Tuyển Dụng 24H';
        $temp['meta'] = array(
            array('name' => 'description', 'content' => $news_category->description),
            array('name' => 'keywords', 'content' => $news_category->keywords)
        );
        $temp['data']['categories'] = $news_categories;
        $temp['data']['category'] = $news_category;
        $temp['template'] = 'frontend/news/category';
        $this->load->view("frontend/_layout/default", $temp);
    }

}